<template>
    <NTree block-line default-expand-all show-line :data="props.treeData"
           label-field="name" key-field="id" children-field="children" @update-selected-keys="updateKeys"/>

</template>

<script setup lang="ts">

defineOptions({
  name: 'orgTree'
});

const props = withDefaults(defineProps<{
  // 部门数据
  treeData: Api.SystemManage.OrgTreeType[],
}>(), {
  treeData: () => [],
});

// 定义自定义事件
const emit = defineEmits(['handle-nodeClick']);

// 节点选中项发生变化时的回调函数
const updateKeys = (keys: Array<string | number>) => {
  emit('handle-nodeClick', keys[0])
}

</script>

<style scoped>

</style>
